package com.zz.cinema.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

@Entity
@Table(name = "TS_CUSTOMER")
public class TS_Customer {

	/**
	 * create sequence SEQ_TS_CUSTOMER 
	 * minvalue 80000000 
	 * maxvalue 89999999
	 * start with 80000000
	 * increment by 1
	 * cache 20;
	 */
	@Id
	@GeneratedValue(generator = "sequenceGenerator_TS_CUSTOMER", strategy = GenerationType.SEQUENCE)
	@SequenceGenerator(name = "sequenceGenerator_TS_CUSTOMER", sequenceName = "SEQ_TS_CUSTOMER", initialValue = 80000000, allocationSize = 1)
	private int customerId;
	
	private String nickName;
	
	private String account;
	
	private String password;
	
	private double balance;
	
	private int VIP;	//0-9
	
	private int phone;

	@OneToMany(mappedBy="customer", targetEntity = TS_Record.class, fetch = FetchType.EAGER, cascade = CascadeType.ALL)
	private Set<TS_Record> records = new HashSet<>();

	
	public TS_Customer() {
		super();
	}


	public TS_Customer(String nickName, String account, String password, double balance, int vIP,
			int phone) {
		super();
		this.nickName = nickName;
		this.account = account;
		this.password = password;
		this.balance = balance;
		VIP = vIP;
		this.phone = phone;
	}

	public int getCustomerId() {
		return customerId;
	}


	public void setCustomerId(int customerId) {
		this.customerId = customerId;
	}


	public String getNickName() {
		return nickName;
	}


	public void setNickName(String nickName) {
		this.nickName = nickName;
	}


	public String getAccount() {
		return account;
	}


	public void setAccount(String account) {
		this.account = account;
	}


	public String getPassword() {
		return password;
	}


	public void setPassword(String password) {
		this.password = password;
	}


	public double getBalance() {
		return balance;
	}


	public void setBalance(double balance) {
		this.balance = balance;
	}


	public int getVIP() {
		return VIP;
	}


	public void setVIP(int vIP) {
		VIP = vIP;
	}


	public int getPhone() {
		return phone;
	}


	public void setPhone(int phone) {
		this.phone = phone;
	}


	public Set<TS_Record> getRecords() {
		return records;
	}


	public void setRecords(Set<TS_Record> records) {
		this.records = records;
	}


	@Override
	public String toString() {
		return "TS_Customer [customerId=" + customerId + ", nickName=" + nickName + ", account=" + account
				+ ", password=" + password + ", balance=" + balance + ", VIP=" + VIP + ", phone=" + phone + ", records="
				+ records + "]";
	}
	
}
